*Stata ver. 19.5
*9. sep. 2025
*Kasper M. Hansen, University of Copenhagen, kmh@ifs.ku.dk, www.kaspermhansen.eu
*Data and analysis for the paper:
*Rally-round-the-flag: The case of COVID-19 in Denmark
*Accepted for publication in Scandinavian Political Studies *
*9 September 2025



*setting working folder
cd "C:\Users\czj968\Dropbox\a_FV22\Kapitler\kap5_corona\Final_submission\Data"

*load data for table 1 and figure 1
use  "Rally_sep2025_datafile1.dta",clear

*recoding
replace days=days/7 // convert proximity to lockdown into weeks







*Running model 1 for table 1
eststo a: reg a c.days##c.treat [pw=stn] if inst!=0, cluster(inst) // applied regression (with weight and standard error clustered on polling agency). cluster handles heteroskedasticity AND within-cluster correlation.
predict y if inst!=0

*ekstra mention text in article 
eststo a_2: reg a c.days##c.treat if inst!=0 // applied regression (without weight and clustered on agency), not shown in paper, but mentioned in note to table 1
eststo a_3: reg a c.days##c.treat##c.days [pw=stn] if inst!=0, cluster(inst) // no better with squared days in reg, mentioned in text, not in table 1


*Table 1: Support for the Social Democrats as a function of the lockdown (regression coefficients)
esttab a, b(2) se(2) r2(2) // in paper as table 1

esttab a_2, b(2) se(2) r2(2) // Mentioned in note to table 1
esttab a_3, b(2) se(2) r2(2) // Mentioned text below table 1






*Figure 1: Support for the Social Democrats during the election period (percentage support)
scatter y date if inst!=0 & date<=date("11mar2020","DMY"), lc(black%80) msymbol(none) msize(small) connect(1)  || ///
scatter y date if inst!=0 & date>date("11mar2020","DMY"), lc(black%80) msymbol(none) msize(small) connect(1)  || ///
scatter a date if inst==3, mc(orange%40) mlc("200 3 44%0")  msymbol(o) msize(small) connect(none)  || ///
scatter a date if inst==7, mc(yellow%70) mlc("200 3 44%0")  msymbol(o) msize(small) connect(none)  || ///
scatter a date if inst==2, mc("blue%40") mlc("200 3 44%0")  msymbol(o) msize(small) connect(none)  || ///
scatter a date if inst==8, mc("grey%50") mlc("200 3 44%0")  msymbol(o) msize(small) connect(none)  || ///
scatter a date if inst==5, mc("red%50") mlc("200 3 44%0")  msymbol(o) msize(small) connect(none)  || ///
scatter a date if inst==0, lcolor("200 3 44") lpattern(solid) lwidth(medthick) msymbol(none) msize(small) mcolor(gs0) connect(l)  ///
graphregion(color(white)) title("") ytitle("", size(thick) ///
margin(medsmall)) xtitle("", margin(small)) tlabel(05jun2019 "5 Jun 19:Election" 01sep2019"1 Sep 19" 01nov2019"1 Nov 19" 01jan2020"1 Jan 20" 11mar2020"11 Mar:Lockdown" 01may2020"1 May 20" 01jul2020"1 Jul 20" ///
01sep2020"1 Sep 20" 01nov2020"1 Nov 20" 01jan2021"1 Jan 21" 01mar2021"1 Mar 21" 01may2021"1 May 21" 01jul2021"1 Jul 21" ///
01sep2021"1 Sep 21" 01nov2021"1 Nov 21" 01jan2022"1 Jan 22" ///
01mar2022"1 Mar 22" 01may2022"1 May 22" 01jul2022"1 Jul 22" 01sep2022"1 Sep 22" 01nov2022"1 Nov 22:Election", format(%td) angle(45) labsize(vsmall) nogrid) tline(11mar2020, lcolor(black%30) lpattern(-)) ///
ylabel(0 (2) 40,labsize(vsmall) angle(0) grid) yscale(r(0 40))  ///
legend(order(8 "Risbjerg Average of polls" 1 "Predicted support for Social Democrats " 3 "{it:YouGov} for {it:BT}" 4 "{it:Megafon} for {it:Politiken} & {it:TV 2}" 5 "{it:Kantar Public} for {it:Berlingske} ({it:Gallup})" 6 "{it:Voxmeter} for {it:Ritzau}" 7 "{it:Epinion} for {it:DR} & {it:Altinget}") col(3) size(vsmall) keygap(1) rowgap(0) colgap(0) span position(6)) 

*save figure 1 in pdf
gr export rally_figure1.pdf,replace













*Loading data for tabel 2 and figure 2
use "Rally_sep2025_datafile2.dta",replace


*recoding
replace days=days/7 // convert proximity to lockdown into weeks


*Table 2 in paper
eststo b: reg total_no_dk c.days##c.treat##c.days [pw=n] // applied regression (with sample weights)
predict yhat // saving predicted values

esttab b, b(2) se(2) r2(2) label // Table 2 in paper
*estout b using b.rtf, cells(b(star fmt(2)) se(par fmt(2))) stats(r2 N) replace // Table 2 in paper, this just take it out of State i rft-format




*Figure 2: Perception of how well Mette Frederiksen is performing as Prime Minister (percentage).
scatter total_no_dk end , mc("200 3 44") mlc("200 3 44%0")  msymbol(o) msize(small) connect(none) || ///
scatter yhat end if end <=date("11mar2020","DMY"), lc(black%80) msymbol(none) msize(small) connect(1)  || ///
scatter yhat end if end >date("11mar2020","DMY"), lc(black%80) msymbol(none) msize(small) connect(1)  ///
graphregion(color(white)) title("") ytitle("", size(thick) ///
margin(medsmall)) xtitle("", margin(small)) tlabel(05jun2019 "5 Jun 19:Election" 01sep2019"1 Sep 19" 01nov2019"1 Nov 19" 01jan2020"1 Jan 20" 11mar2020"11 Mar:Lockdown" 01may2020"1 May 20" 01jul2020"1 Jul 20" ///
01sep2020"1 Sep 20" 01nov2020"1 Nov 20" 01jan2021"1 Jan 21" 01mar2021"1 Mar 21" 01may2021"1 May 21" 01jul2021"1 Jul 21" ///
01sep2021"1 Sep 21" 01nov2021"1 Nov 21" 01jan2022"1 Jan 22" ///
01mar2022"1 Mar 22" 01may2022"1 May 22" 01jul2022"1 Jul 22" 01sep2022"1 Sep 22" 01nov2022"1 Nov:Election", format(%td) angle(45) labsize(vsmall) nogrid) tline(11mar2020, lcolor(black%30) lpattern(-)) ///
ylabel(0 (5) 80, labsize(vsmall) angle(0)) yscale(r(0 80))  ytitle("Believes, Frederiksen preforms good as Prime Minister", size(small)) ///
legend(order(1 "Preforms good" 2 "Predicted value, that the Priminister preforms good ") col(2) size(small) keygap(1) rowgap(0) colgap(3) span position(6)) 



*save figure 2 in pdf
gr export rally_figure2.pdf,replace

